import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
	{
    title: '班级',
    align:"center",
    dataIndex: 'departName'
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'personName'
   },
   {
    title: '学号',
    align:"center",
    dataIndex: 'personCode'
   },
   {
    title: '隐患情况描述',
    align:"center",
    dataIndex: 'hiddenTrouble'
   },
   {
    title: '处理措施',
    align:"center",
    dataIndex: 'handlingMeasures'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "班级",
      field: 'deptId',
      component: 'JSelectDept',
      //colProps: {span: 6},
 	},
	{
      label: "姓名",
      field: 'personName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "学号",
      field: 'personCode',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "隐患情况描述",
      field: 'hiddenTrouble',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "处理措施",
      field: 'handlingMeasures',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '人员',
    field: 'personId',
    component: 'JSelectPerson',
    componentProps: {
      labelKey: 'name',
    },
    // dynamicDisabled: ({ values }) => {
    //   return values.dataType==2;
    // },
    // component: 'JPopup',
    // componentProps: ({ formActionType }) => {
    //     const {setFieldsValue} = formActionType;
    //     return{
    //         setFieldsValue:setFieldsValue,
    //         code:"select_person",
    //         fieldConfig: [
    //             { source: 'id', target: 'personId' },
    //         ],
    //         multi:true
    //     }
    // },

    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择人员!'},
          ];
     },
  },
  {
    label: '隐患情况描述',
    field: 'hiddenTrouble',
    component: 'InputTextArea',
  },
  {
    label: '处理措施',
    field: 'handlingMeasures',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  personId: {title: '人员',order: 1,view: 'popup', type: 'string',code: 'select_person', orgFields: 'id', destFields: 'personId', popupMulti: false,},
  hiddenTrouble: {title: '隐患情况描述',order: 2,view: 'textarea', type: 'string',},
  handlingMeasures: {title: '处理措施',order: 3,view: 'textarea', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}